package com.baobao.demo;

import java.util.concurrent.ExecutionException;

import org.springframework.stereotype.Component;

import com.squareup.okhttp.Response;

@Component
public class HystrixUtil {

	public Response execute(String url) throws InterruptedException, ExecutionException {

		CommandHelloWorld c = new CommandHelloWorld(url);// 同步执行
		Response s = c.execute();
		System.out.println("断路器状态" + c.isCircuitBreakerOpen() + ",url:" + url);
		return s;
		// Future<Response> future = new MyHystrixCommand(setter,
		// url).queue();//异步执行
		// return future.get();//需要时获取

	}

}